package com.geguo.mvptest;

import android.os.Bundle;
import android.os.HandlerThread;
import android.support.v7.app.AppCompatActivity;
import android.widget.Button;
import android.widget.TextView;

import com.geguo.mvptest.interfaces.IView;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;


public class MainActivity extends AppCompatActivity implements IView {

    @Bind(R.id.tv_show)
    TextView tvShow;
//  按钮
    @Bind(R.id.btn_show)
    Button btnShow;
    private Presenter presenter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);
//      在View中创建Presenter对象，将事件处理代码放到Presenter中
        presenter = new Presenter(this);
        presenter.onCreate();
    }


    @OnClick(R.id.btn_show)
    public void onClick() {
//      事件代码放到Presenter中
        presenter.preformClick();
    }

    @Override
    public void setData(final String data) {

        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                tvShow.setText(data);
            }
        });

    }
}
